import Vue from 'vue'
import ElementUI from 'element-ui'
import VueEasyCm from 'vue-easycm-hotkey'
import './theme/element/#2680EB/index.css'
import './assets/iconfont/iconfont.css'
import 'v-charts/lib/style.css'
import App from './App.vue'
import router from './router'
import store from './store'
import request from './js/request'
import './js/directives'
// import './js/mock'
import VCharts from 'v-charts'
import {
    isEmpty
} from './js/tool'
import ShortKey from 'vue-shortkey-yt'
import 'lib-flexible/flexible.js'
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/index.css'
import echarts from 'echarts'
import walden from './theme/echarts/walden.json' // 引用echarts主题
echarts.registerTheme('walden', walden) // 注册主题到echarts中

Vue.config.productionTip = false
Vue.use(ElementUI, {
    zIndex: 3000
})
Vue.use(VueEasyCm)
Vue.use(VCharts)
Vue.use(VXETable)
Vue.use(ShortKey, {
    prevent: ['input', 'textarea']
})

// let USER_TOKEN = 'cae26ebfc0a54a39b2e0da35633d19b6cd11cb19efe6457ce5c8305f32fe206a59763a247662f8ceabcbd7fb42aad4d7f148c1c4a4ef6a86c3fd3bcf40efc87bb6208e46aad29fb25c550e7b8713454bf625f1c4324f86af241884e3c5a082ae75b2da27f7357ac9b93b6047d2cc2e258914f0da21d55d460ca79c1d42bd0864095f61209d681cc0'
// localStorage.setItem('USER_TOKEN', JSON.stringify(USER_TOKEN))
Vue.prototype.$post = request.post
Vue.prototype.$download = request.download
Vue.prototype.$isEmpty = isEmpty
Vue.prototype.$echarts = echarts

/* eslint-disable */

router.beforeEach((to, from, next) => {
    if (!localStorage.getItem('USER_TOKEN')) {
        ElementUI.Message.error('登录过期，请重新登录')
        window.location.href = `${location.origin}/index.html#/login`
    } else {
        next()
    }
})

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
